//---------------------------------------------------------------------------
#ifndef LoanShopH
#define LoanShopH
//---------------------------------------------------------------------------
#include <vcl.h>
#include "LoanArticle.h";

class LoanShop
{
	static const int NUM_ARTICLES1 = 25;  // store capacity of shop
	private:
	AnsiString id1;		 // the id of this shop
	AnsiString name1;     // the name of this shop
	LoanArticle** articles1;  // holds the articles of this shop,
						 // the names of the articles in this array are unique.
	int nrOfArticles1;    // the number of articles
	int nrOfPurchases1;	 // the number of purchases
	int purchaseIdList1[NUM_ARTICLES1]; // the list of articles to sell
	int purchaseQtList1[NUM_ARTICLES1]; // the list of quantity to sell

	/*
	If there exists an article with articleID id,
	it returns the index of that article in the array articles,
	else it returns -1
	same for the second method only this one checks the purchase
	*/
	int getIndexOfArticle1(int id1);
	int getIndexOfPurchase1(int id1);

	public:
	//constructors

	/*
	this constructor creates a Shop-object with a name
	as specified with the parameter of this constructor.
	*/
	LoanShop(AnsiString id1, AnsiString name1);

	/*
	this destructor makes sure there are no memory leaks
	*/
	~LoanShop();


	//methods (functions)

	/*
	returns the article on index i in the array articles
	i should have a value between 0 and nrOfArticles (0<=i<nrOfArticles)
	the same for the second method but this one checks for the
	articles in the purchase array
	*/
	LoanArticle* getArticleAtIndex1(int i1);
	LoanArticle* getPurchaseAtIndex1(int i1);

	/*
	Get the id/quantity of a purchase at index i
	*/
	int getPurchaseIdAtIndex1(int i1);
	int getPurchaseQtAtIndex1(int i1);

	/*
	some get functions
	*/
	AnsiString getID1();
	AnsiString getName1();
	int getCapacity1();
	int getNrOfArticles1();
	int getNrOfPurchases1();

	/*
	If there exists already an article with name nm or if
	nrOfArticles>=NUM_ARTICLES the function addArticle returns false.
	In the other case an article with id, name, nrOfItems, kind and price
	as specified with the parameters of the function,
	is added to the array, nrOfArticles is incremented by 1
	and the function returns true.
	*/
	bool addArticle1(int id1, AnsiString nm1, int nrOfItems1, AnsiString kind1, double price1, double deposit1);

	/*
	The method soldSome() checks if the nrOfItems is bigger than the amount to remove.
	If so, the number of items of that article is decreased by amount
	and the return value is true. If not, the return value is false.
	The method unsoldSome() is just the the opposite.
	The method unSoldAll() just clears all purchases and add them back to the stock.
	The method clearAllPurchases() just clears all purchases without adding them to the stock.
	The method totalPrice() returns the total price.
	*/
	bool soldSome1(int id1, int amount1);
	bool unsoldSome1(int id1, int amount1);
	void unsoldAll1();
	void clearAllPuchases1();
	double getTotalPrice1();

	//new function for loan shop
	bool unsoldBroken1(int id1, int amount1);

	//*** A method to make the loan shop work
	bool insertGuestLoanToPurchase1(int id1, int qt1);

	/*
	The function sortAllArticlesByName will sort the articles in the array
	by their name, descending.
	*/
	void sortAllArticlesByName1();

	/*
	The function sortAllArticlesBySalesValue will sort the articles in the array
	by their sales value, descending.
	*/
	void sortAllArticlesBySalesValue1();

	/*
	The function sortAllArticlesByKind will sort the articles in the array
	by their kind.
	*/
	void sortAllArticlesByKind1();
};
//---------------------------------------------------------------------------
#endif
